<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Documentation PHPIDS for MODx: Instructions</title>

    <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
  </head>
  <body>
    <h1><a name="instructions"><span /></a>Instructions</h1>
    <h2><a name="download"><span /></a>Download</h2>
    <p>
      First you need to download the package and unpack the zip file. You will 
      find the current version at <a href="https://code.google.com/p/phpids-for-modx/downloads/list">https://code.google.com/p/phpids-for-modx/downloads/list</a>.
    </p>
    <h2><a name="upload"><span /></a>Upload</h2>
    <p>
      Upload the folders lib and modules in the assets directory of your existing MODx installation with a FTP client program.<br />
      Change the access rights of <code>assets/lib/phpids/lib/IDS/tmp</code> to 777.
    </p>
    <h2><a name="secure_the_PHPIDS_directory"><span /></a>Secure the PHPIDS directory</h2>
    <p>
      The folder <code>assets/lib/phpids</code> and the sub-folder is secured with 
      a .htaccess file, that denies all possible access from the web. If you use 
      a Microsoft Windows OS with IIS, you should secure the folder with IIS 
      properties, because IIS does not understand .htaccess files.
    </p>
    <h2><a name="Installation_and_configuration"><span /></a>Installation and configuration of the module</h2>
    <p>
      Open the file <code>assets/module/phpids/module.phpids.inc.php.tpl</code> and copy the content.<br />
      Go to your MODx backend, click on the tab "Modules" &#8658; "Manage Modules" &#8658; New Module".
    </p>
    <p>
      Name the module PHPIDS and paste the copied code into "Module code (php)".
    </p>
    <p>
      <image style="height: 550px; width: 736px;" alt="Create the module" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-1-module.jpg" />
    </p>
    <h3><a name="Module_Configuration"><span /></a>Configuration</h3>
    <p>
      Now click on "Configuration", there you have to enable parameter sharing and paste the following line into "Module configuration" and click "Update parameter display".
    </p>
    <pre>
      <code>&amp;useMODxBasePath=Use MODx base path?;list;true,false;true &amp;basePath=PHPIDS path?;string;assets/lib/phpids/lib &amp;useLogFile=Use log file?;list;true,false;false &amp;useEmail=Use email?;list;true,false;true &amp;useDatabase=Use database?;list;true,false;true &amp;useMODxTablePrefix=Use MODx table prefix?;list;true,false;true &amp;useMODxLog=Use MODx Log?;list;true,false;true &amp;logFromImpact=Start logging from impact?;int;5 &amp;sendMailFromImpact=Start sending mails from impact, high (around 15) or very high (around 25-50) impact?;int;15 &amp;idsRecipients=Mail resipients (separated by comma);text; &amp;idsSubject=Mail subject (keep empty to use default);text; &amp;SMTPServer=SMPT server;text; &amp;SMTPPort=SMPT port (default is 25, leave empty to use default);text; &amp;SMTPAccount=SMPT account;text; &amp;SMTPPassword=SMPT password;text; &amp;mailFrom=E-Mail From Name Only used with SMTP;text;PHPIDS;&amp;useExeptions=Exceptions separated with pipes (|);text;&amp;blockedDocumentID=ID of the MODx document, that blocked IPs would see, default is root;text&amp;defaultTableEntries=Default table entries on start;text;20 &amp;redirectIntrusionLevel=Redirect intrusions from a level (50 is hight);text;50 &amp;redirectIntrusionID=Redirect intrusion to the document ID (0 means no redirection);text;0 &amp;csvDelimiter=CSV delimiter (only one character);text;, &amp;csvEnclosure=CSF enclosure (only one character);text;#</code>
    </pre>
    <p>
      <image style="height: 547px; width: 740px;" alt="Create the module" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-2-module.jpg" />
    </p>
    <p>
      Now you can change the configuration of the plugin and the module. All 
      parameters, that are not personally as the e-mail address, where the 
      impacts should be reported, are filled with default values.
    </p>
    <p>
      Click on "Save" and the first module step is done.
    </p>
    <h3><a id="Parameter_description"><span /></a>Parameter description</h3>
    <table class="parameters" border="0" cellpadding="0" cellspacing="0">

      <colgroup><col width="264" /><col width="523" /></colgroup><tbody>
        <tr>
          <td>
          <p>Use MODx base path</p>
          </td>
          <td>
          <p>Use the base path of the current MODx installation.</p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
            PHPIDS path?
            </p>
          </td>
          <td>
            <p>
              Path to the PHPIDS files. You may want to use only one PHPIDS for 
              different MODx installations, then you have to configure the path.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Use log file?
            </p>
          </td>
          <td>
            <p>
              Weather to use a log file, or not.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Use email?
            </p>
          </td>
          <td>
            <p>
              Weather to send alarm mails, or not.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Use database?
            </p>
          </td>
          <td>
            <p>
              Weather to write logs to the database, or not.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Use MODx table prefix?
            </p>
          </td>
          <td>
            <p>
              If you use database logs, you may decide to use the MODx tabel prefix, 
              or not.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Use MODx Log?
            </p>
          </td>
          <td>
            <p>
              Weather you want to use the MODx log, or not.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Start logging from impact?
            </p>
          </td>
          <td>
            <p>
              Define the lower limit for impacts where the logging starts.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Start sending mails from impact, high (around 15) or very high 
              (around 25-50) impact?
            </p>
          </td>
          <td>
            <p>
              Define the level of impacts,at which mail sending starts.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Mail recipients (separated by comma)
            </p>
          </td>
          <td>
            <p>
              Enter the mail recipients, that you want to inform about possible 
              attacks.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Mail subject <br />
              (keep empty to use default)
            </p>
          </td>
          <td>
            <p>
              Write your own subject text, or leave it empty to use the default text.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              SMPT server
            </p>
          </td>
          <td>
            <p>
              If you want to use a SMTP server for sending mails, enter the address 
              to the server here.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              SMPT port <br />
              (default is 25, leave empty to use default)
            </p>
          </td>
          <td>
            <p>
              The port of the SMTP Server, leave it empty if your server uses the 
              default SMTP port.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              SMPT account
            </p>
          </td>
          <td>
            <p>
              The SMTP account name.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              SMPT password
            </p>
          </td>
          <td>
            <p>
              The password for the SMTP account.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              E-Mail From Name<br />
              Only used with SMTP
            </p>
          </td>
          <td>
            <p>
              The name, that will be used as from text on SMTP mails.
            </p>
          </td>
        </tr>
        <tr>
          <td>
          <p>
            Exceptions separated with pipes (|)
          </p>
          </td>
          <td>
            <p>
              Here you can define exceptions for PHPIDS, for example to avoid alarms
              of Google Analytics.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              ID of the MODx document, where blocked IPs are send to
            </p>
          </td>
          <td>
            <p>
              Here you can enter an MODx document identifier, where blocked IP 
              addresses are forwarded to. For example you may setup a static HTML 
              page and forward the attacker to the static page.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Default table entries on start
            </p>
          </td>
          <td>
            <p>
              The number of table entries, that are used inside the module, when you 
              open the module. You can change the the table entries also in the 
              table.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Redirect intrusions from a level (50 is very high)
            </p>
          </td>
          <td>
            <p>
              The level of intrusions to redirect possible attackers automatically 
              to a document.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              Redirect intrusion to the document ID (0 means no redirection)
            </p>
          </td>
          <td>
            <p>
              If you want to redirect possible attackers with a high impact rate
              automatically, you can enter an MODx document identifier, where blocked
              IP addresses are forwarded to. For example you may setup a static HTML
              page and forward the attacker to the static page.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              CSV delimiter (only one character)
            </p>
          </td>
          <td>
            <p>
              The delimiter for the CSV cells. Only one character is allowed.
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              CSF enclosure (only one character)
            </p>
          </td>
          <td>
            <p>
              The enclosure for CSV text cells. Only one character is allowed.
            </p>
          </td>
        </tr>
      </tbody>
    </table>

    <h2><a name="Installation_and_configuration_of_the_plugin"><span /></a>Installation and configuration of the plugin</h2>
    <h3><a name="Plugin_Installation"><span /></a>Installation</h3>
    <p>
      Open the file assets/plugins/phpids/plugin.phpids.inc.php.tpl and copy the content.<br />
      In your MODx backend click on "Elements" &#8658; "Manage Elements" &#8658; "Plugins" &#8658; "New Plugin".
    </p>
    <p>
      Name the plugin PHPIDS and paste the copied content into "Plugin code (php)".
    </p>
    <p>
      <image style="height: 548px; width: 742px;" alt="Create the plugin" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-3-plugin.jpg" />    
    </p>
    <h3><a name="Plugin_Configuration"><span /></a>Configuration</h3>
    <p>
      Then go to "System Events" and under "Template Service Events" choose "OnWebPageInit", then click on save.
    </p>
    <p>
      <image style="height: 546px; width: 742px;" alt="Configuration of the plugin" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-4-plugin.jpg" />    
    </p>
    <h2><a name="Configuration of the module to use the module configuration in the plugin"><span /></a>Configuration of the module to use the module configuration in the plugin</h2>
    <h3><a name="Allow the use plugin at the module"><span /></a>Allow the use plugin at the module</h3>
    <p>
      Go back the module by "Modules" &#8658; "Manage Modules" &#8658; "PHPIDS" and then 
      on the tab "Dependencies". Now click "Manage Dependencies" and there on 
      "Add Plugin".
    </p>
    <p>
      <image style="height: 412px; width: 756px;" alt="Module dependencies" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-5-module.jpg" />    
    </p>
    <p>
      Here you only have to click on "Insert" and then on "Close".
    </p>
    <p>
      <image style="height: 382px; width: 759px;" alt="Module dependencies" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-6-module.jpg" />    
    </p>
    <p>
      No go back to "Elements" &#8658; "Manage Elements" &#8658; "Plugins" and edit 
      "PHPIDS". Open tab "Configuration" and choose "PHPIDS" in the drop down 
      box "Import Module shared parameters".
    </p>
    <p>
      <image style="height: 483px; width: 1018px;" alt="Plugin Element selector" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-7-module.jpg" />    
    </p>
    <h3><a name="Use the parameters of the module in the plugin"><span /></a>Use the parameters of the module in the plugin</h3>
    <p>
      Open the plugin again and click on the configuration. On "Import Module 
      shared parameters" choose PHPIDS.
    </p>
    <p>
      <image style="height: 417px; width: 757px;" alt="Plugin Configuration: Shared parameters" src="https://phpids-for-modx.googlecode.com/git/evolution/docs/images/instruction-examples/instruction-create-step-9-plugin.jpg" />    
    </p>
  </body>
</html>

